﻿workflow Start-MUILanguageReportGeneration
{
    $computers=(Get-ADComputer -Filter {(name -notlike "*v-*")}).Name | Sort-Object 
    
    foreach -Parallel($computer in $computers)
    {
        InlineScript 
        {
            $connectionTest=Test-Connection -Count 1 -ComputerName $Using:computer -ErrorAction SilentlyContinue
            if($connectionTest)
            {
                Write-Output "Retrieving MUILanguages from $Using:computer"
                $muiLanguages=(gwmi -Class Win32_OperatingSystem -ComputerName $Using:computer  | Select MUILanguages).MUILanguages
                foreach($muiLanguage in $muiLanguages)
                {
                    New-Object PSObject -Property @{ComputerName=$using:computer;MUILanguage=$muiLanguage}| Export-csv -Path c:\codeplex\windows\MUILanguages\$using:computer.csv -NoTypeInformation -Append
                }
                
            }
            else
            {
                Write-Output "Cannot reach $Using:computer"
            }
        }
    }
}

Start-MUILanguageReportGeneration

Get-ChildItem .\MUILanguages\*.csv | ForEach-Object {Import-Csv $_} | Export-Csv -NoTypeInformation MUILanguagesReport.csv